<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="//res.layui.com/layui/dist/css/layui.css"  media="all">
</head>
<body>
<div>aaaa</div>
<input type = "button" value="333" onclick="add()">
<input type = "button" value="444" onclick="history.back()">
<a type = "button" value="55" href="history2.html">555</a>
<script>
  window.onpopstate = function(event) {
      console.log("location: " + document.location + ", state: " + JSON.stringify(event.state));
      //window.history.go(1)
      //window.history.back()
   };
 
  var state = {
         title: "title",
         url: "#"
      };
       window.history.pushState(state, "title", "history.html?bb=1");

function add(){
	!function() {
      var state = {
         title: "title",
         url: "#"
      };
      window.history.pushState(state, "title", "history.html?aa==1");
   }();
   
	if (window.history && window.history.pushState) {

   //window.addEventListener("popstate", function(e) {
   //   window.location = 'http://www.baidu.com';
   //}, false);
 
   //!function() {
   //   var state = {
   //      title: "title",
   //      url: "#"
   //   };
   //   window.history.pushState(state, "title", "#");
   //}();
 
}
	}

</script>

</body>
</html>